package com.example.echoewish.ui.my_activity.my_friend_activity;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.example.echoewish.econstant.UserInfo;
import com.example.echoewish.pojo.Friend;
import com.example.echoewish.pojo.MyConcern;
import com.example.echoewish.repository.ConcernMessageRepository;
import com.example.echoewish.util.LogUtil;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MyConcernViewModel extends ViewModel {
    public MutableLiveData<List<MyConcern>> friendMutableLiveData;
    public MutableLiveData<String> responseMutableLiveData;

    public MyConcernViewModel()
    {
        friendMutableLiveData=new MutableLiveData<>();
        responseMutableLiveData=new MutableLiveData<>();
    }

    public void getMyFriendMessage()
    {
        ConcernMessageRepository.getInstance().getMyConcern(UserInfo.getInstance().UserId,new GetMyConcernCallBack());
    }

    private class GetMyConcernCallBack implements Callback<List<MyConcern>>
    {

        @Override
        public void onResponse(Call<List<MyConcern>> call, Response<List<MyConcern>> response) {
            friendMutableLiveData.postValue(response.body());
        }

        @Override
        public void onFailure(Call<List<MyConcern>> call, Throwable t) {
            friendMutableLiveData.postValue(null);
            new LogUtil().w(LogUtil.CALLBACK_TAG,"获取我关注的用户信息 回调失败"+t);
        }
    }
}
